﻿
namespace Marmat.Forms.Views.Grid
{
    public class CustomRowCellEditEventArgs : CustomRowCellEventArgs
    {
        internal DevExpress.XtraGrid.Views.Grid.CustomRowCellEditEventArgs args;

        internal CustomRowCellEditEventArgs(BaseGrid gridControl, DevExpress.XtraGrid.Views.Grid.CustomRowCellEditEventArgs args) : base(gridControl, args.RowHandle, (Column)args.Column.Tag)
        {
            this.args = args;
        }


        /// <summary>
        /// 使用指定的用户控件进行编辑
        /// </summary>
        /// <value></value>
        /// <returns></returns>
        /// <remarks></remarks>
        public EditControl EditControl
        {
            get
            {
                return this._EditControl;
            }

            set
            {
                this._EditControl = value;
                if (this.EditControl is null || this.EditControl.m_BaseEdit is null)
                {
                    this.RepositoryItem = null;
                }
                else
                {
                    this.RepositoryItem = (DevExpress.XtraEditors.Repository.RepositoryItem)this.EditControl.m_BaseEdit.Properties.Clone();
                }
            }
        }

        private EditControl _EditControl;

        /// <summary>
        /// 获取或设置用于编辑当前处理单元格的编辑器。
        /// </summary>
        /// <returns></returns>
        public DevExpress.XtraEditors.Repository.RepositoryItem RepositoryItem
        {
            get
            {
                return this.args.RepositoryItem;
            }

            set
            {
                this.args.RepositoryItem = value;
            }
        }

        /// <summary>
        /// 获取当前行。
        /// </summary>
        /// <returns></returns>
        public new object Row
        {
            get
            {
                return GridControl.GetRow(this.RowHandle);
            }
        }
    }
}